package licode.unisop.realm.application.service;

import cn.hutool.json.JSONUtil;
import licode.unisop.provider.api.SiAuthenticationInterceptor;
import licode.unisop.provider.info.SiAuthContext;

/**
 * 定义远程的用户认证拦截器
 *
 * @author licode
 */
public class SiAuthenticationInterceptorUrl extends SiUrlCallBase implements SiAuthenticationInterceptor {
    public SiAuthenticationInterceptorUrl(SiRestfulCallUtil callUtil, String url) {
        super(callUtil, url);
    }

    @Override
    public boolean onBefore(SiAuthContext context) {
        String result = execute("onBefore", JSONUtil.toJsonStr(context));
        return null != result && Boolean.getBoolean(result);
    }

    @Override
    public void onAfter(SiAuthContext context) {
        execute("onAfter", JSONUtil.toJsonStr(context));
    }
}
